package list;

import java.util.ArrayList;

import org.jivesoftware.smack.XMPPConnection;

import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ListView;

import com.example.androidhw06_tab.MyListActivity;
import com.example.androidhw06_tab.R;

public class ListTab extends Fragment {

	ListView list;
	ConvListAdapter mAdapter;
	ArrayList<MyConvList> mList = new ArrayList<MyConvList>();
	
	
	@Override
	public void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		
		
	}
	
	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container,
			Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		View v = inflater.inflate(R.layout.fragment_list, container, false);
		
		list = (ListView)v.findViewById(R.id.conversationlist);
		mAdapter = new ConvListAdapter(getActivity(), mList);
		list.setAdapter(mAdapter);
		
		list.setOnItemClickListener(new OnItemClickListener() {

			@Override
			public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,
					long arg3) {
				// TODO Auto-generated method stub
				Intent intent = new Intent(getActivity(), MyListActivity.class);
				startActivity(intent);
			}
			
		});
		
		return v;
	}
}
